<#include "../common/layout/__mainlayout.html">
    <#include "../common/__pagination.html">
    <!--设置面包屑-->
    <#assign pageBreadCrumbs>
        <li class="active"><a href="#">应用推荐</a></li>
        <li class="active">运营推荐管理列表</li>
    </#assign>

<#assign pageCss>
    <!-- page specific plugin styles -->
    <link rel="stylesheet" href="${ctx}/static/admin/assets/css/jquery-ui.custom.css" />
    <link rel="stylesheet" href="${ctx}/static/admin/assets/css/select2.css" />
    <link rel="stylesheet" href="${ctx}/static/admin/assets/css/chosen.css"/>
    <link rel="stylesheet" href="${ctx}/static/admin/assets/css/datepicker.css"/>
    <link rel="stylesheet" href="${ctx}/static/admin/assets/css/daterangepicker.css"/>
</#assign>
<#assign pageJavascript>
    <script type="text/javascript">
        $(document).ready(function(){
            $("#state").val(${query.state!});
            $('[data-rel=tooltip]').tooltip();

            if(!ace.vars['touch']) {
                $('.chosen-select').chosen({allow_single_deselect:true});
            }

            // 清除远程modal数据
            $("#editModal").on("hidden.bs.modal", function () {
                $(this).removeData("bs.modal");
            });

            //初始化范围选择器
            $('input[name=createTimeRange]').daterangepicker({
                'applyClass': 'btn-sm btn-success',
                'cancelClass': 'btn-sm btn-default',
                locale: {
                    applyLabel: '确定',
                    cancelLabel: '取消'
                },
                startDate:new Date()

            });

            //初始化范围选择器
            $('input[name=startTimeRange]').daterangepicker({
                'applyClass': 'btn-sm btn-success',
                'cancelClass': 'btn-sm btn-default',
                locale: {
                    applyLabel: '确定',
                    cancelLabel: '取消'
                },
                startDate:new Date()
            });

            $("#editModal").on("hidden.bs.modal", function(){
                $(this).removeData("bs.modal");
            });

            // 删除按钮
            $("a.delete").on(ace.click_event, function(e){
                var currentA = this;
                var title = $(currentA).attr("title");
                e.preventDefault();
//                bootbox.setDefaults({locale:"zh_CN"});
                bootbox.confirm({
                            message: "确定"+title+"该运营推荐的软件?",
                            buttons: {
                                confirm: {
                                    label: "确定",
                                    className: "btn-primary btn-sm"
                                },
                                cancel: {
                                    label: "取消",
                                    className: "btn-sm"
                                }
                            },
                            callback: function(result) {
                                if(result){
                                    $.ajax({
                                        type: "POST",
                                        url: $(currentA).attr("href"),
                                        dataType: 'text',
                                        success: function(msg){
                                            var msg = eval("("+msg+")");
                                            if(msg.result == "success"){
                                                $("#searchForm").submit();
//                                                window.location="${refer!}";
                                            }else{
                                                alert(msg.messages);
                                                //bootbox.alert(msg.messages);
                                            }
                                        },
                                        error: function(){
                                            bootbox.alert("删除失败");
                                        }
                                    });
                                }
                            }
                        }
                );
            });

        });
    </script>
</#assign>

<@mainlayout pageBreadCrumbs=pageBreadCrumbs pageCss=pageCss pageJavascript=pageJavascript currentMenu="recommendFlag-softRecRankFlag">
    <div class="row">
        <div class="col-xs-12">
            <form id="searchForm" action="${ctx}/admin/softRecRank/softRecRankList.html" class="form-search form-inline" method="GET">

                <div class="row">
                    <div class="widget-body">
                        <div class="widget-main">
                            <div class="form-group  col-xs-12" style="padding-top:10px">
                                <label class="col-xs-1 text-right" for="softIds">应用编号:</label>
                                <input type="text" id="softIds" name="softId" class="input-sm col-xs-2"  value="${query.softId!}"/>
                                <label class="col-xs-1 text-right"  for="startTimeRange">运营推荐时间:</label>
                                <input type="text" id="startTimeRange" name="startTimeRange" readonly="readonly" class="input-sm col-xs-2"   value="${query.startTimeRange!}"/>
                                <label class="col-xs-1 text-right"for="state">状态:</label>
                                <select class="col-xs-1" name="state" id="state"  data-placeholder="状态">
                                    <option value="-99">全部</option>
                                    <option value="0" selected>显示</option>
                                    <option value="-1">删除</option>
                                </select>
                                <input type="button" id="searchBtn" class="btn btn-sm btn-primary" value="查询"/>&nbsp;
                                <a href="${ctx}/admin/softRecRank/viewSoftRecRank.do" class="btn btn-sm btn-warning" data-toggle="modal" data-target="#editModal"><i class="ace-icon fa fa-plus"></i>添加</a>
                                <input type="reset" id="reset" class="btn btn-sm btn-danger" data-toggle="modal" />
                            </div>

                        </div>
                    </div>
                </div>

                <table id="softRecRankTable" class="table table-striped table-bordered table-hover">
                    <thead>
                    <tr>
                        <th width="40" align="center">应用编号</th>
                        <th width="100" align="center">应用名称</th>
                        <th width="100" align="center">开始时间</th>
                        <th width="100" align="center">结束时间</th>
                        <th width="100" align="center">显示顺序</th>
                        <th width="100" align="center">操作</th>
                    </tr>
                    </thead>
                    <tbody id="softtbody">
                        <#list softRecRankList.listData as softMap>
                            <tr>
                                <td  align="center">${softMap.softId!}</td>
                                <td  align="center">${softMap.softName!}</td>
                                <td  align="center">${softMap.startTimeShow!}</td>
                                <td  align="center">${softMap.expiredTimeShow!}</td>
                                <td  align="center">${softMap.rankNumber!}</td>
                                <td  align="center">
                                    <#if softMap.state == -1>
                                        <a class="green tooltip-success delete"
                                           href="${ctx}/admin/softRecRank/changeSoftRecRank.do?softRecRankId=${softMap.id}&state=0" data="${softMap.id!}" title="显示"  data-toggle="tooltip"><span
                                                class="label label-success">显示</span></a>
                                    </#if>
                                    <#if softMap.state != -1>
                                        <a class="green tooltip-success edit"
                                           href="${ctx}/admin/softRecRank/viewSoftRecRank.do?softRecRankId=${softMap.id}" data="${softMap.id!}"  data-toggle="modal" data-target="#editModal"><span
                                                class="label label-success">修改</span></a>
                                        <a class="red tooltip-error delete"
                                           href="${ctx}/admin/softRecRank/deleteSoftRecRank.do?softRecRankId=${softMap.id!}" data-rel="tooltip"
                                           title="删除"> <span class="label label-danger">删除</span></a>
                                    </#if>
                                </td>
                            </tr>
                        </#list>
                    </tbody>
                </table>
                <@pagination softRecRankList!/>
            </form>
        </div>
    </div>

    <div id="editModal" class="modal fade" data-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content">
            </div>
        </div>
    </div>
</@mainlayout>